package com.feixiu.controller;

import com.feixiu.pojo.ApprovalRecords;
import com.feixiu.service.ApprovalRecordsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/records")
public class ApprovalRecordsCon {
    @Autowired
    private ApprovalRecordsService approvalRecordsService;
    @RequestMapping("/getall")
    @ResponseBody
     List<ApprovalRecords> getAllRecords(String account){
         return approvalRecordsService.getAllRecords(account);
     }
    @RequestMapping("/getApproval")
    @ResponseBody
    List<ApprovalRecords> getAllApprovalRecords(String account){
        return approvalRecordsService.getAllApprovalRecords(account);
    }
    @RequestMapping("/getFinish")
    @ResponseBody
    List<ApprovalRecords> getFinishRecords(String recordno){
        return approvalRecordsService.getFinishRecords(recordno);
    }
    @RequestMapping("/refuse")
    @ResponseBody
    String refuse(ApprovalRecords records){
        String s="false";
       if (approvalRecordsService.refuse(records)){
           s="true";
       }
       return s;
    }
    @RequestMapping("/agree")
    @ResponseBody
    String  getFinishRecords(ApprovalRecords records){
        String s="false";
        if (approvalRecordsService.agree(records)){
            s="true";
        }
        return s;
    }
    @RequestMapping("/add")
    @ResponseBody
    String  addRecords(String processname, String account,String opinion){
       Boolean flag=approvalRecordsService.approvalAdd(processname,account,opinion);
       if (flag){
           return "true";

       }
       return "false";
    }
}
